package yl.hs.bmipfull.controllers.finance;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yl.hs.bmipfull.controllers.ControllerBase;
import yl.hs.bmipfull.service.finance.IReceiptLedgerService;
import yl.hs.bmipfull.service.material.IPurchaseContractService;
import yl.hs.bmipfull.viewmodels.PageQuery;
import yl.hs.bmipfull.viewmodels.WebResult;

/*
 * ReceiptLedgerController 采购付款台账控制器
 * @category 财务管理——采购付款台账
 * @author 谢景广
 * @date 2022-01-10
 */
@Api(value = "入库结算数据接口", tags = "财务管理——采购付款台账")
@RequestMapping(path = "/api/finance/receiptLedger/")
@RestController
public class ReceiptLedgerController extends ControllerBase {

    @PostMapping("/{rowNum}/{page}")
    @ApiOperation(value = "查询合同台帐信息", notes = "分页查询合同台帐信息" )
    public WebResult queryPage(@ApiParam(value = "查询") @RequestBody PageQuery query, @PathVariable Integer page, @PathVariable Integer rowNum){
        try {
            var contractResult = pcSvc.queryPages(query,rowNum,page);
            var result = rlSvc.convertToLedger(contractResult);
            return success("ok",result);
        } catch (Exception e) {
            return error(e);
        }
    }

    @Autowired
    public void setPcSvc(IPurchaseContractService pcSvc) {
        this.pcSvc = pcSvc;
    }

    @Autowired
    public void setRlSvc(IReceiptLedgerService rlSvc) {
        this.rlSvc = rlSvc;
    }

    IReceiptLedgerService rlSvc;
    IPurchaseContractService pcSvc;
}
